package cn.kingshion.juc.locks;

/**
 *
 */
public class Thread8Monitor {
    public static void main(String[] args) {
        Numbers numbers = new Numbers();
        Numbers numbers2 = new Numbers();
        new Thread(() -> {
            numbers.getOne();
        }).start();

        new Thread(() -> {
            numbers2.getTwo();
        }).start();

        /*new Thread(() -> {
            numbers.getThree();
        }).start();*/
    }
}

class Numbers {
    public  synchronized void getOne() {
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("one");
    }

    public  synchronized void getTwo() {
        System.out.println("two");
    }

    public void getThree() {
        System.out.println("three");
    }
}
